import os.path


def to_abs_path(path):
    return os.path.join(project_path, path)


def ensure_pdir_exist(path):
    """
    确保父目录存在
    """
    if check_pdir_exist(path):
        return
    else:
        os.makedirs(get_pdir(path), exist_ok=True)


def check_pdir_exist(path):
    """
    检查父目录是否存在
    """
    return os.path.exists(get_pdir(path))


def check_file_exist(path):
    """
    检查文件是否存在
    """
    return os.path.exists(path)


def get_pdir(path):
    """
    获取父目录
    """
    return os.path.dirname(path)


project_path = get_pdir(os.path.dirname(__file__))

print(project_path)